#include <memory>
#include "tcp_server.hpp"
#include "err.hpp"
#include "daemon.hpp"
using namespace std;
using namespace tcp_server;

static void usage(char* proc)
{
    cout << "Usage:\n\t" << proc << " port\n" << endl;
}

string echo(const string& message)
{
    return message;
}

int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        usage(argv[0]);
        exit(USAGE_ERR);
    }
    uint16_t port = atoi(argv[1]);
    unique_ptr<TcpServer> tsvr(new TcpServer(echo, port));
    tsvr->InitServer();
    Daemon();
    tsvr->Start();
    return 0;
}